﻿<?php

/**
 * @author HuyHoang
 * @copyright 2011
 */

include('class.phpmailer.php');
include('class.smtp.php');

class FeedbacksController extends AppController {
    var $name = 'Feedbacks';
    var $helpers = array('Html','Ajax','Javascript','Form');
    var $paginate = array(
        'limit' => 10
    );
    
    function index($id = null) {
        $this->layout = "home";
        $data = $this->paginate('Feedback');
        $this->set('feedbacks', $data);
    }
    
    function save() {
        $this->redirect(array("action" => "index", $this->Customer->id));
    }
    
    function sendMail() {
        
        $content = $_REQUEST['feContent'];
        $from = "huy.hoang.programmer@gmail.com";
        $to = "huy.hoang.programmer@gmail.com";
        $name = "admin";

        $mail = new PHPMailer();
                 $mail->IsSMTP();
                 $mail->Host = "smtp.gmail.com";
                 $mail->Port = 587;
                 $mail->Timeout = 60;
                 $mail->SMTPAuth = true;
                 $mail->SMTPSecure = 'tls';
                 $mail->Username = "huy.hoang.programmer";
                 $mail->Password = "bachkhoa";
                 $mail->From = $from;
                 $mail->FromName = "admin";
                 $mail->AddAddress("huy.hoang.programmer@gmail.com", "Huy Hoang");
                 $mail->WordWrap = 50;
                 $mail->IsHTML(true);
                 $mail->Subject = "Thong bao lay lai mat khau ";
                 $mail->Body = "<b>Mat khau cua ban la: , xin vui long nhan vao <a href='#'>day</a> de tro ve trang chu</b>";
                 $mail->AltBody = "Thank you!";      
        $mail->Send();
    }
    
    function delete($id = null) {
        $this->redirect(array("action" => "index"));
    }
}

?>
